gbfputc(0x01, file_out); // Proximity alarm. 1 == "off", 3 == armed.
ident = mkshort(mkshort_handle, wpt->shortname);
- strncpy(tbuf, wpt->shortname, sizeof(tbuf));
+ strncpy(tbuf, CSTRc(wpt->shortname), sizeof(tbuf));
tbuf[sizeof(tbuf)-1] = 0;
gbfwrite(tbuf, sizeof(tbuf), 1, file_out);
CSV_STRINGCLEAN(const char* string, const char* chararray,DEBUG_PARAMS);
#define csv_stringclean(s,c) CSV_STRINGCLEAN(s,c,__FILE__,__LINE__)
#endif
+QString csv_stringclean(const QString& string, const char* chararray);
void
xcsv_data_read(void);
le_write32(&ewpt.data.wp_altitude, METERS_TO_FEET(wpt->altitude) + 1000);
}
if (wpt->shortname != NULL) {
- ewpt.shortname_len = min(6, strlen(wpt->shortname));
- strncpy(ewpt.shortname, wpt->shortname, 6);
+ ewpt.shortname_len = min(6, strlen(CSTRc(wpt->shortname)));
+ strncpy(ewpt.shortname, CSTRc(wpt->shortname), 6);
}
if (wpt->description != NULL) {
- ewpt.longname_len = min(27, strlen(wpt->description));
- strncpy(ewpt.longname, wpt->description, 27);
+ ewpt.longname_len = min(27, strlen(CSTRc(wpt->description)));
+ strncpy(ewpt.longname, CSTRc(wpt->description), 27);
}
gbfwrite(&ewpt, sizeof(ewpt), 1, file_out);
}
}
}
static void
-fwrite_string(gbfile* fd, QString& str)
+fwrite_string(gbfile* fd, const QString& str)
{
if (str.isEmpty()) {
fwrite_integer(fd, 0);
}
}
+void
+fwrite_fixedstring(gbfile* fd, const QString& str, int fieldlen)
+{
+ fwrite_fixedstring(fd, CSTR(str), fieldlen);
+}
+
/* Auxiliar functions */
#define MAX_INDATUM_INDEX 263
}
static void
-lowranceusr4_writestr(char* buf, gbfile* file, unsigned int bytes_per_char)
+lowranceusr4_writestr(const QString& buf, gbfile* file, unsigned int bytes_per_char)
{
unsigned int len = 0;
- if (buf) {
- len = strlen(buf);
- }
+ len = buf.length();
if (0xffffffff / bytes_per_char < len) {
/* be pedantic and check for the unlikely event that we are asked
gbfputint32(len*bytes_per_char, file_out);
if (bytes_per_char == 1) {
- (void) gbfwrite(buf, 1, len, file);
+ (void) gbfwrite(CSTR(buf), 1, len, file);
} else {
for (unsigned int i = 0; i < len; ++i) {
- gbfputc(buf[i], file_out);
+ gbfputc(buf[i].cell(), file_out);
for (unsigned int j = 1; j < bytes_per_char; ++j) {
gbfputc('\0', file_out);
}
same_points(const waypoint* A, const waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
+#if NEW_STRINGS
+ (A->shortname == B->shortname) &&
+#else
(strcmp(A->shortname, B->shortname) == 0) &&
+#endif
(A->latitude == B->latitude) &&
(A->longitude == B->longitude));
}
QString mag_find_token_from_descr(const QString& icon);
unsigned int mag_checksum(const char* const buf);
-char* m330_cleanse(char* istring);
+char* m330_cleanse(const char* istring);
waypoint* mag_trkparse(char* trkmsg);
void mag_rteparse(char* rtemsg);
/*=================== File read/write utilities ==========================================*/
static void
-ng_fwrite_wp_data(char* s, char* d, ng_wp_data_t* wp_data, gbfile* f)
+ng_fwrite_wp_data(const QString& s, const QString& d, ng_wp_data_t* wp_data, gbfile* f)
{
int i;
char z[50];
memset(z, 0, 50);
-
- i = (s == NULL) ? 0 : strlen(s);
+ i = s.length();
gbfwrite(&i, 1, 1, f);
- gbfwrite(s, 1, i, f);
+ gbfwrite(CSTR(s), 1, i, f);
gbfwrite(&wp_data->pad1[0], 8, 1, f);
gbfputint32(wp_data->East, f);
gbfwrite(&wp_data->pad2[0], 2, 1, f);
gbfputint32(wp_data->Alt, f);
- i = (d == NULL) ? 0 : strlen(d);
+ i = d.length();
gbfwrite(&i, 1, 1, f);
- gbfwrite(d, 1, i, f);
+ gbfwrite(CSTR(d), 1, i, f);
gbfwrite(z, 44, 1, f);
}
static void
ng_waypt_rd(const waypoint* wpt)
{
- char* s = NULL;
-
char z[50];
double lat, lon;
static int current_wp_ix=0;
WPNC.wp_data.North = (int32_t)lat;
WPNC.wp_data.East = (int32_t)lon;
+ String s;
if (reorder_wp) {
sprintf(temp_short_name, "A%03d", current_wp_ix);
s = temp_short_name;
gbfprintf(file_out, "W %-6.6s %c%08.5f %c%011.5f %s %5.f %-40.40s %5e %d\n",
global_opts.synthesize_shortnames ?
mkshort_from_wpt(mkshort_handle, wpt) :
- wpt->shortname,
+ CSTRc(wpt->shortname),
lat < 0.0 ? 'S' : 'N',
fabs(lat),
lon < 0.0 ? 'W' : 'E',